package com.herench.bs.handler;


import com.herench.bs.agent.IInHosAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;

import java.util.Map;


/**
 * Created by liuxiaohui on 2019/3/26.
 */
@Component
@Handler(code = "200122",name="复印病例预约缴费：ChargeAppointMedPrint()")
public class ChargeAppointMedPrintHandler extends AbstractMessageHandler {

    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());

        // **************** 微信前端传入的参数 ******************************************* Start
        // 系统编码：微信前端区分医院用
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");

        // 复印病例预约ID
        String medAppId = requestMessage.getArgsPropertyStringValue("medAppId");
        // 卡号
        String cardNo = requestMessage.getArgsPropertyStringValue("cardNo");
        // 卡类型
        String cardType = requestMessage.getArgsPropertyStringValue("cardType");
        // 支付类别
        String moneyType = requestMessage.getArgsPropertyStringValue("moneyType");
        // 流水号
        String streamNo = requestMessage.getArgsPropertyStringValue("streamNo");
        // 批次号
        String batchCode = requestMessage.getArgsPropertyStringValue("batchCode");
        // 授权码
        String authorizationCode = requestMessage.getArgsPropertyStringValue("authorizationCode");
        // 终端编号
        String terminalNumber = requestMessage.getArgsPropertyStringValue("terminalNumber");
        // 银行编码
        String bankCode = requestMessage.getArgsPropertyStringValue("bankCode");
        // 银行名称
        String bankName = requestMessage.getArgsPropertyStringValue("bankName");
        // 参考号
        String reference = requestMessage.getArgsPropertyStringValue("reference");

        // **************** 微信前端传入的参数 ******************************************* End

        // 医院代码：微信后端区分医院用
        String hospitalCode = getCleverClinicContext().getHospitalCodeByChannelCode(channelCode);

        // 获取Bean信息
        IInHosAgent inHosAgent = getCleverClinicContext().getApplicationContext().getBean(IInHosAgent.class);
        // 设定入参
        Map<String, Object> res = inHosAgent.chargeAppointMedPrint(channelCode, hospitalCode, medAppId, cardNo, cardType, moneyType, streamNo, batchCode, authorizationCode, terminalNumber, bankCode, bankName, reference);

        // 设置应答信息
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage, res);

        return responseMessage;
    }
}
